package com.learn.test.spi;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class SpiMysqlMain {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        // SPI机制：无需手动编写Class.forName("com.mysql.cj.jdbc.Driver")
        //  Driver到底满不满足SPI机制？首先看目录结构满不满足约定，外部库中找到对应包发现满足的
        //  Driver到底满不满足SPI机制？其次看文件内容满不满足约定，外部库中找到对应包发现满足的
        //  SPI机制的实现代码体现在何处呢？以getConnection为入口查看源码（todo 没找到😂）
        Connection connectionSpi = DriverManager.getConnection("jdbc:mysql://localhost:3306/learn_sql", "root", "makabaka");
        System.out.println(connectionSpi);
        
        // 非SPI机制
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/learn_sql", "root", "makabaka");
        System.out.println(connection);
    }
}
